import {BasicColumn} from '/@/components/Table';
import {FormSchema} from '/@/components/Table';
import { rules} from '/@/utils/helper/validator';
import { render } from '/@/utils/common/renderUtils';
import { getWeekMonthQuarterYear } from '/@/utils';
//列表数据
export const columns: BasicColumn[] = [
   {
    title: '部门',
    align:"center",
    dataIndex: 'orgCode_dictText'
   },
   {
    title: '姓名',
    align:"center",
    dataIndex: 'realname'
   },
   {
    title: '联系电话',
    align:"center",
    dataIndex: 'phone'
   },
   {
    title: '角色名称',
    align:"center",
    dataIndex: 'roleName'
   },
   {
    title: '特情类型',
    align:"center",
    dataIndex: 'leaveType_dictText'
   },
   {
    title: '开始时间',
    align:"center",
    dataIndex: 'startTime'
   },
   {
    title: '结束时间',
    align:"center",
    dataIndex: 'endTime'
   },
   {
     title: '创建时间',
     align:"center",
     dataIndex: 'createTime'
   },
   {
     title: '状态',
     align:"center",
     dataIndex: 'status_dictText'
   },
];
//查询数据
export const searchFormSchema: FormSchema[] = [
  {
    label: '姓名',
    field: 'realname',
    component: 'JInput',
  },
  {
    label: '联系电话',
    field: 'phone',
    component: 'JInput',
  },
  {
    label: '角色',
    field: 'roleCode',
    component: 'JDictSelectTag',
    componentProps: ({ formModel, formActionType }) => {
      return {
        dictCode: 'sys_role,role_name,role_code,role_code!="admin"',
      }
    },
  },
  {
    label: '特情类型',
    field: 'leaveType',
    component: 'JDictSelectTag',
    componentProps: ({ formModel, formActionType }) => {
      return {
        dictCode: 'user_leave_type',
      }
    },
  },
  {
    label: '状态',
    field: 'status',
    component: 'JDictSelectTag',
    componentProps: ({ formModel, formActionType }) => {
      return {
        dictCode: 'user_leave_status',
      }
    },
  },
  {
    label: '部门',
    field: 'orgCode',
    component: 'JDictSelectTag',
    componentProps: ({ formModel, formActionType }) => {
      return {
        dictCode: 'sys_depart,depart_name,org_code,org_code like "A01A%"',
      }
    },
  },
  {
    label:'创建时间',
    field:'createTime',
    component:"DatePicker",
    componentProps: {
      format: 'YYYY-MM-DD',
      valueFormat: 'YYYY-MM-DD'
    },
    colProps: {
      span: 6,
    },
  },

];
//表单数据
export const formSchema: FormSchema[] = [
  {
    label: '部门',
    field: 'orgCode',
    component: 'JDictSelectTag',
    componentProps: ({ formModel, formActionType }) => {
      return {
        dictCode: 'sys_depart,depart_name,org_code,org_code like "A01A%"',
        onChange: (e) => {
          let { updateSchema } = formActionType;
          console.log('onChange=', e);
          updateSchema(
          {
            field: 'userId',
            componentProps: () => {
              return {
                dictCode: `sys_user,realname,id,org_code="${e ? e : -1}"`
              }
            },
          }
          )
        }
      }
    },
    dynamicRules: ({model,schema}) => {
        return [
               { required: true, message: '请选择部门!'},
        ];
   },
  },
  {
    label: '用户',
    field: 'userId',
    component: 'JDictSelectTag',
    componentProps: () => {
      return {
        dictCode: 'sys_user,realname,id,org_code="A01A01"',
      }
    },
    dynamicRules: ({model,schema}) => {
        return [
               { required: true, message: '请选择用户!'},
        ];
   },
  },
  {
    label: '特情类型',
    field: 'leaveType',
    component: 'JDictSelectTag',
    componentProps: () => {
      return {
        dictCode: 'user_leave_type',
      }
    },
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请选择特情类型!'},
          ];
     },
  },
  {
    label: '开始时间',
    field: 'startTime',
    component: 'DatePicker',
    componentProps: {
       showTime: true,
       valueFormat: 'YYYY-MM-DD HH:mm:ss'
     },
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入开始时间!'},
          ];
     },
  },
  {
    label: '结束时间',
    field: 'endTime',
    component: 'DatePicker',
    componentProps: {
       showTime: true,
       valueFormat: 'YYYY-MM-DD HH:mm:ss'
     },
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入结束时间!'},
          ];
     },
  },
  {
    label: '备注',
    field: 'remark',
    component: 'InputTextArea',
  },
	// TODO 主键隐藏字段，目前写死为ID
	{
	  label: '',
	  field: 'id',
	  component: 'Input',
	  show: false
	},
];

// 高级查询数据
export const superQuerySchema = {
  tenantId: {title: '租户号',order: 0,view: 'text', type: 'string',},
  orgCode: {title: '部门编码',order: 2,view: 'text', type: 'string',},
  userId: {title: '用户id',order: 3,view: 'text', type: 'string',},
  username: {title: '用户名',order: 4,view: 'text', type: 'string',},
  realname: {title: '真实姓名',order: 5,view: 'text', type: 'string',},
  phone: {title: '电话',order: 6,view: 'text', type: 'string',},
  userType: {title: '用户类型;用户类型：teacher/教员；student/学员；user/普通用户；',order: 7,view: 'text', type: 'string',},
  roleCode: {title: '角色编码',order: 8,view: 'text', type: 'string',},
  roleName: {title: '角色名称',order: 9,view: 'text', type: 'string',},
  seatId: {title: '席位id',order: 10,view: 'text', type: 'string',},
  leaveType: {title: '特情类型',order: 11,view: 'text', type: 'string',},
  startTime: {title: '开始时间',order: 12,view: 'datetime', type: 'string',},
  endTime: {title: '结束时间',order: 13,view: 'datetime', type: 'string',},
  remark: {title: '备注',order: 14,view: 'text', type: 'string',},
};

/**
* 流程表单调用这个方法获取formSchema
* @param param
*/
export function getBpmFormSchema(_formData): FormSchema[]{
  // 默认和原始表单保持一致 如果流程中配置了权限数据，这里需要单独处理formSchema
  return formSchema;
}
